import { ip } from "./libs/_env";

const { appVersion, appWgtVersion } = uni.getSystemInfoSync();

const SERVER_URL = {
  // 开发环境服务地址(若H5版本前端处理跨域开启代理则和前端资源服务器地址一致即可)
  development: {
    URL_ASSETS: `http://${ip}:3101`,  // 前端资源服务地址
    URL_REMOTE: `http://${ip}:3101`, // 后端接口地址
    URL_WEBSOCKET: null,
    DEBUG_MODE: true
  },

  // 生产环境服务地址(若H5版本前后端在同一项目下，接口和资源地址一致即可)
  production: {
    URL_ASSETS: "https://h5.ylshuzi.com", // 前端资源服务地址
    URL_WEBSOCKET: null,
    DEBUG_MODE: false,
    // #ifdef APP-PLUS
    ...{ URL_REMOTE: "http://mark.ylshuzi.com" }, // 后端接口地址
    // #endif
    // #ifdef H5
    ...{ URL_REMOTE: "" },
    // #endif
  },
}

const config = {
  ...(SERVER_URL[process.env.NODE_ENV as keyof typeof SERVER_URL]),
  ASSETS_PREFIX: "",
  API_PREFIX: "/api",

  API_CHECK_VERSION: "/appVersion",
  API_USER_INFO_GET: "/userInfo",
  API_USER_INFO_SET: "/perfectUserInfo",
  API_FILE_UPLOAD: "/uploadImage",
  API_CONFIG_GET: null,

  URL_REMOTE_ASSETS: "http://images.smart0006.cn",

  PAGE_LOGIN_APPLETS: null,
  PAGE_HOME_CLIENT: "/pages/client/tabs/home",
  PAGE_LOGIN_ACCOUNT: "/pages/client/auth/login",
  PAGE_NOT_FOUND: "/pages/common/error",
  PAGE_UPGRADE: "/pages/common/upgrade/index",

  PATH_STATIC: "/static/server",
  STORAGE_KEY_USER_INFO: "userInfo",
  STORAGE_USER_INFO_EXPIRE_TIME: 7,
  FIELD_TOKEN: "token",

  SIGN_KEY: "97003ee0a511884cfa7b2b561e0cd112",

  COLOR_0: "transparent",
  COLOR_1: "#000",
  COLOR_2: "#fff",
  COLOR_3: "#333",
  COLOR_4: "#ff0404",
  COLOR_5: "#3b86f6",
  COLOR_6: "#666",
  COLOR_7: "#1d1d1d",
  COLOR_9: "#999",
  COLOR_10: "#56bdfc",

  VERSION: appWgtVersion || appVersion,
};

let URL_STATIC = config.PATH_STATIC;
// #ifdef MP
URL_STATIC = config.URL_ASSETS + URL_STATIC;
// #endif

export default Object.assign(config, { URL_STATIC }, uni.getStorageSync("$config") || {});
